<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <%= csrf_meta_tag %>
    <%= stylesheet_link_tag :all %>
    <%= stylesheet_link_tag 'markitup/sets/markdown/style' %>
    <%= stylesheet_link_tag 'markitup/skins/woniu/style' %>
    <%= javascript_include_tag :defaults %>
    <%= javascript_include_tag "jquery", "jquery-ui", "jrails" %> 
    <script>$j = jQuery.noConflict();</script>
    <%= javascript_include_tag 'markitup/jquery.markitup' %>
    <%= javascript_include_tag 'markitup/sets/markdown/set' %>
  </head>

  <body>
    <div id="show_sidebar_box">
      <div><%= t(".show_sidebar") %></div>
      <div id="sidebar_box" style="display:none">
        <%= form_tag '', :method => :get do %>
          <%= t(".local") %>
          <%= select_tag("locale", options_for_select(VALID_LANG, I18n.locale), { :index => nil, :onchange => 'this.form.submit()'}) %>
        <% end %>
	<div id="login_status">
          <% if logged? %>
            <div><%= t(".hello") %>,<%= @current_user.username %>!</div>
            <div>
            <%= button_to Profile.model_name.human, user_profile_url(@current_user.id), :method => :get %>
            <%= button_to t("logout"), logout_path, :method => :delete %>
	    </div>
            <%= link_to t(".my_articles"), user_articles_path(@current_user) %>
            <%= link_to t(".new_article"), new_user_article_path(@current_user) %>
          <% else %>
            <%= form_tag login_path do %>
              <%= hidden_field_tag :last_uri, request.fullpath %>
              <%= User.human_attribute_name("username") %>:
              <%= text_field_tag :username, params[:username] %>
              <%= User.human_attribute_name("password") %>:
              <%= password_field_tag :password%>
              <%= t("remember_me") %>!<%= check_box_tag :remember_me %>
              <%= submit_tag t("login") %>
          <% end %>
          <%= link_to t("register"), register_path %>
        <% end %>
        </div>
      </div>
    </div>

    <div id="main_frame">
      <div id="main_frame_info">
	<span id="logo"><%= link_to "", root_path, :remote => true %></span>
	<span id="logo_name"><%= link_to "Republic!理想国", root_path, :remote => true %></span>
	<% if flash[:notice] %>
	  <div id="notice"><%= notice %></div>
	<% end %>
	<div id="main_body_info">
	  <span id="page_number"></span>
	  <span id="article_info"></span>
	</div>
      </div>
      <div id="main_body">
	<%= yield %>
      </div>
    </div>

    <% if (ENV["RAILS_ENV"] == "development")&&false %>
      <fieldset id="debugbox">
	<legend>Debug Info</legend>
	<label id="debug_params_label" onclick="$j('#debug_params').toggle('fast', function(){})">Debug for Params</label>|
	<label id="debug_session_label" onclick="$j('#debug_session').toggle('fast', function() {})">Debug for Session</label>|
	<label id="debug_variable_label" onclick="$j('#debug_variable').toggle('fast', function() {})">Debug for Variable</label>|

	<fieldset id="debug_params" class="debug_info" style="display:none">
	  <legend>Params Info</legend>
	  <%= debug(params) %>
	</fieldset>

	<fieldset id="debug_session" class="debug_info" style="display:none">
	  <legend>Session Info</legend>
	  <%= debug(session) %>
	</fieldset>

	<fieldset id="debug_variable" class="debug_info" style="display:none">
	  <legend>Variable Info</legend>
	  <%= @current_user ? @current_user.username : "" %>
	  <%= @articles ? @articles : "" %>
	</fieldset>

      </fieldset>
    <% end %>
  </body>
</html>
